﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Amazon.SimpleDB;
using Amazon.SimpleDB.Model;
using Amazon.SimpleDB.Util;

namespace PennyStorm.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to PennyStorm!";

            //
            // Get a list of 10 auctions that are ending soon
            //
            AmazonSimpleDBClient sdb = new AmazonSimpleDBClient(Properties.Settings.Default.key, Properties.Settings.Default.secret);
           
            SelectRequest selectRequest = new SelectRequest();
            selectRequest.SelectExpression = string.Format("select * from {0} limit 10", Properties.Settings.Default.domain);

            SelectResponse response = sdb.Select(selectRequest);
            ViewData["Top10Items"] = response.SelectResult.Item;

            return View();
        }
       
        public ActionResult About()
        {
            return View();
        }
    }
}
